
local table = table 
local error = error

module(...,package.seeall)

--Place where all protoypes are stored
repository = {}

--> Search for fields
function search (list,k)
  local i,p
  for i,p in pairs(list) do
    local v = p[k]
    if v then 
      return v 
    end
  end
end

function fieldlist(list)
 local i,p
 local k,v
 local fields = {}
 for i,p in pairs(list) do
   for k,v in pairs(p) do 
     table.insert(fields,k)
   end
 end
 return fields
end

function new(...)
  local all = {...}
  local p ={}
  local t,k,v
  printd(#all)
  if #all >= 1 then
    for _,t in pairs(all) do
      for k,v in pairs(t) do
        if p[k] ~= nil then
          error("conflicting prototypes")
        end
        printd(k,v)
        p[k] = v
      end
    end
  end  
  table.insert(repository,p)
  return p
end
